import { createSlice } from "@reduxjs/toolkit";
import axios from "axios";
const AsyncSend = createSlice({
  name: "send",
  initialState: {
    msg: [],
  },
  reducers: {
    fetchData(state, { payload }) {
      state.msg = payload;
    },
  },
});
const { fetchData } = AsyncSend.actions;
const fetchList = () => {
  return (dispatch) => {
    axios.get("http://localhost:3200/data").then((res) => {
      dispatch(fetchData(res.data));
    });
  };
};
export { fetchList };
const reducer = AsyncSend.reducer;
export default reducer;
